package logger

import (
	"github.com/gogf/gf/v2/errors/gerror"
	"github.com/gogf/gf/v2/frame/g"
	"github.com/gogf/gf/v2/os/glog"
)

func InitGLogger(logPath string) {
	logger := glog.New()
	err := logger.SetConfig(glog.Config{
		Path:                 logPath,
		File:                 "{Y-m-d}.log",
		Prefix:               "",
		Level:                16,
		TimeFormat:           "2006-01-02 15:04:05",
		CtxKeys:              nil,
		HeaderPrint:          false,
		StdoutPrint:          false,
		RotateSize:           1024 * 1024 * 100, // 100MB
		RotateExpire:         7,                 // 7 days
		RotateBackupLimit:    30,                // 30 days
		RotateBackupExpire:   7,                 // 7 days
		RotateBackupCompress: 0,                 // 0 means no compress
		RotateCheckInterval:  1,                 // 1 minute
		StdoutColorDisabled:  true,              // false means color output
		WriterColorEnable:    true,              // true means color output
	})
	if err != nil {
		g.Log().Errorf(nil, "err:%+v", gerror.Wrap(err, "日志初始化报错"))
	}
}
